<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- Alt + Shift + F ：格式化html-->
    <div id="app">
        <ul>
            <li v-for="user in userList">
                {{user.id}} ==> {{user.name}} == {{user.gender}}

                =={{user.gender==1?"男":"女"}}

                ==局部过滤器： {{user.gender | genderFilter}}<br />
                全局过滤器：{{user.gender | gFilter}}
            </li>
        </ul>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.filter("gFilter", function (val) {
            if (val == 1) {
                return "男~~";
            }
            else {
                return "女~~";
            }
        })
        new Vue({
            el: "#app",
            data: {
                userList: [{ "id": 1, "name": "jack", "gender": 1 }, { "id": 2, "name": "peter", "gender": 0 }]
            },
            filters: {
                genderFilter(val) {
                    if (val == 1) {
                        return "男";
                    }
                    else {
                        return "女";
                    }
                }
            }
        });
    </script>
</body>

</html>